﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using asMeishi.web.Models;

using MongoDB.Bson;
using MongoDB.Driver.Linq;
using MongoDB.Bson.Serialization.Attributes;

namespace asMeishi.web.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            //DataSession<MongoDataContext, testx> textxdb = new DataSession<MongoDataContext, testx>();
            //var noi = new ObjectId();
            //var a1 =new testx(){  p0=noi.ToString(), q0= noi, s0 = noi, strId=noi.ToString(), x0=noi};
            //var a2 =new testx() {  p0 = noi.ToString(), q0 = noi, s0 = noi, strId = noi.ToString(), x0 = noi };
            //textxdb.Add(a1);
            //textxdb.Add(a2);
            //return Content("");

            return View();
        }

        public ActionResult About()
        {
            return View();
        }
        //[OutputCache(Duration=3600)]
        public ActionResult Main()
        {

            return View();
        }

        [HttpPost]
        public ActionResult LogOn(string email, string password, string url = "/")
        {
            if (!userC.login(email, password))
                TempData["info"] = "错误的用户名或密码";
            return new RedirectResult(url); 
        }

        public ActionResult LogOff()
        {
            userC.logout();
            return new RedirectResult("/");
        }


    }
}
